package com.manage.project.biz.controller;

import java.util.List;

import com.manage.project.biz.domain.BizShebei;
import com.manage.project.biz.service.IBizShebeiService;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.manage.framework.aspectj.lang.annotation.Log;
import com.manage.framework.aspectj.lang.enums.BusinessType;
import com.manage.project.biz.domain.BizJidiansheshijingchangjianxiu;
import com.manage.project.biz.service.IBizJidiansheshijingchangjianxiuService;
import com.manage.framework.web.controller.BaseController;
import com.manage.framework.web.domain.AjaxResult;
import com.manage.common.utils.poi.ExcelUtil;
import com.manage.framework.web.page.TableDataInfo;

/**
 Controller
 *
 * @author liutao
 *
 */
@RestController
@RequestMapping("/biz/jidiansheshijingchangjianxiu")
public class BizJidiansheshijingchangjianxiuController extends BaseController
{
    @Autowired
    private IBizJidiansheshijingchangjianxiuService bizJidiansheshijingchangjianxiuService;
    @Autowired
    private IBizShebeiService bizShebeiService;

    /**
     * 查询机电设施经常检修列表
     */
//    @PreAuthorize("@ss.hasPermi('biz:jidiansheshijingchangjianxiu:list')")
    @GetMapping("/list")
    public TableDataInfo list(BizJidiansheshijingchangjianxiu bizJidiansheshijingchangjianxiu)
    {
        startPage();
        List<BizJidiansheshijingchangjianxiu> list = bizJidiansheshijingchangjianxiuService.selectBizJidiansheshijingchangjianxiuList(bizJidiansheshijingchangjianxiu);
        return getDataTable(list);
    }

    /**
     * 导出机电设施经常检修列表
     */
//    @PreAuthorize("@ss.hasPermi('biz:jidiansheshijingchangjianxiu:export')")
    @Log(title = "机电设施经常检修", businessType = BusinessType.EXPORT)
    @GetMapping("/export")
    public AjaxResult export(BizJidiansheshijingchangjianxiu bizJidiansheshijingchangjianxiu)
    {
        List<BizJidiansheshijingchangjianxiu> list = bizJidiansheshijingchangjianxiuService.selectBizJidiansheshijingchangjianxiuList(bizJidiansheshijingchangjianxiu);
        ExcelUtil<BizJidiansheshijingchangjianxiu> util = new ExcelUtil<BizJidiansheshijingchangjianxiu>(BizJidiansheshijingchangjianxiu.class);
        return util.exportExcel(list, "机电设施经常检修数据");
    }

    /**
     * 获取机电设施经常检修详细信息
     */
//    @PreAuthorize("@ss.hasPermi('biz:jidiansheshijingchangjianxiu:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return AjaxResult.success(bizJidiansheshijingchangjianxiuService.selectBizJidiansheshijingchangjianxiuById(id));
    }

    /**
     * 新增机电设施经常检修
     */
//    @PreAuthorize("@ss.hasPermi('biz:jidiansheshijingchangjianxiu:add')")
    @Log(title = "机电设施经常检修", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody BizJidiansheshijingchangjianxiu bizJidiansheshijingchangjianxiu)
    {
//        String shebeiID = bizJidiansheshijingchangjianxiu.getField4();
//        List<BizShebei> listShebei = bizShebeiService.selectBizShebeiByShebeiId(shebeiID);
//        if (listShebei.size()!=0){
//            return AjaxResult.error("该设备不存在！");
//        }
        return toAjax(bizJidiansheshijingchangjianxiuService.insertBizJidiansheshijingchangjianxiu(bizJidiansheshijingchangjianxiu));
    }

    /**
     * 修改机电设施经常检修
     */
    @Log(title = "机电设施经常检修", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody BizJidiansheshijingchangjianxiu bizJidiansheshijingchangjianxiu)
    {
        return toAjax(bizJidiansheshijingchangjianxiuService.updateBizJidiansheshijingchangjianxiu(bizJidiansheshijingchangjianxiu));
    }

    /**
     * 删除机电设施经常检修
     */
//    @PreAuthorize("@ss.hasPermi('biz:jidiansheshijingchangjianxiu:remove')")
    @Log(title = "机电设施经常检修", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids)
    {
        return toAjax(bizJidiansheshijingchangjianxiuService.deleteBizJidiansheshijingchangjianxiuByIds(ids));
    }
}
